home *** CD-ROM | disk | FTP | other *** search
- /*
- File: StorageClassDriver.h
-
- Contains: xxx put contents here xxx
-
- Version: xxx put version here xxx
-
- Copyright: © 1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #ifndef __STORAGECLASSDRIVERH__
- #define __STORAGECLASSDRIVERH__
-
- #include <USB.h>
- #include "SampleStorageDriverAPI.h"
-
-
- void DriverEntry(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
- void ExpertNotify(void *exNote);
-
-
- #if DEBUG
- #define IF_DEBUG(x) x
- #else
- #define IF_DEBUG(x)
- #endif
-
- #define kStrStorageClass "\pStorageClass: "
-
- #define kStorageRetryCount 5
- #define kMaxTransitions 1
- #define kIntDataSize 8
- #define kStatusSize 2 // USB Status
-
- // I/O retry counts
- #define kMaxReadRetries 0
- #define kMaxWriteRetries 0
- #define kMaxDiagRetries 0
-
- typedef CALLBACK_API_C( void , RWCompletion )(USBPB *pb);
-
- // These states are used by StorageDeviceInitiateConfiguration
- enum driverConfigStates
- {
- kUndefined = 0,
-
- kSetConfig,
- kGetFullConfiguration0,
- kGetFullConfiguration1,
- kFindStorageInterface,
- kStorageConfigureInterface,
-
- kNewInterfaceRef,
- kStorageFindInterruptPipe,
- kStorageFindBulkInPipe,
- kStorageFindBulkOutPipe,
- kStorageReadInterrupt,
-
- kStorageBulkRead,
- kStorageBulkWrite,
- kStorageInitiateBulkRead, // Begin a bulk read transaction
- kStorageBulkIOComplete, // Complete the bulk read
- kStorageInitiateBulkWrite, // Begin a bulk write transaction
-
- kStorageBulkWriteComplete, // Complete the bulk write
- kStorageExecuteCommand, // Begin execution of user command
- kStorageExecuteCommandCompletion, // Complete the user command
- kStorageGetStatus, // Complete the GetStatus request
- kStorageGetStatusBulkRead, // Get the status data
-
- kStorageReadFirmwareVersion, // Read the firmware version of the device
- kUSBDelay,
-
- kNilCompletion,
-
- kReturnFromDriver = 0x1000,
- kRetryTransaction = 0x2000,
- kAsyncTransaction = 0x4000,
- kCompletionPending = 0x8000
- };
-
- // Structure for the global PB's
- struct StorageClassTransactionPB {
- USBPB usbPB;
- UInt8 cdb[kCDBSize];
- Ptr bufferPtr;
- UInt32 expectedByteCount;
- UInt32 actualByteCount;
- UInt32 bytesLeftToTransfer;
- UInt32 currentState;
- Boolean busy;
- SInt32 retryCount;
- UInt32 flags; // Flags from StorageClassRequest pb
- StorageBlockRWPBPtr userPBPtr;
- RWCompletion completionProc;
- };
- typedef struct StorageClassTransactionPB StorageClassTransactionPB;
- typedef StorageClassTransactionPB *StorageClassTransactionPBPtr;
-
-
- struct StorageClassInfo {
- USBPB usbPB; // Configuration block
-
- // Device info
- UInt8 firmwareVersion[2];
-
- // Interrupt pipe
- USBPipeRef interruptPipeRef; // USB pipe reference
- UInt8 interruptReport[kIntDataSize];
-
- // mandatory bulk in pipe
- USBPipeRef readPipeRef; // USB pipe reference
-
- // mandatory bulk out pipe
- USBPipeRef writePipeRef; // USB pipe reference
-
- // device: configuration and interface details
- USBDeviceRef interfaceRef; // USB device reference
- USBDeviceRef deviceRef; // USB device reference
- USBConfigurationDescriptorPtr pFullConfigDescriptor;
- USBConfigurationDescriptor partialConfigDescriptor;
-
- USBInterfaceDescriptor interfaceDescriptors[32];
- USBInterfaceRef interfaceRefArray[32];
- USBRqIndex interfaceCount;
- USBRqIndex interfaceIndex;
-
- UInt32 interfaceNumber;
-
- USBDeviceDescriptor deviceDescriptor; // copy for local reference
- USBInterfaceDescriptorPtr pInterfaceDescriptor; // copy for local reference
-
- // class driver async transactions
- SInt32 transDepth; // don't nest transactions
- SInt32 retryCount; // automatically retry transactions
- UInt32 currentState; // State machine state
- };
- typedef struct StorageClassInfo StorageClassInfo;
- typedef StorageClassInfo *StorageClassInfoPtr;
-
-
- struct StorageClassStatusPB {
- USBPB usbPB;
- Boolean busy;
- StorageStatusPBPtr userPBPtr;
- UInt8 status[kStatusSize];
- };
- typedef struct StorageClassStatusPB StorageClassStatusPB;
- typedef StorageClassStatusPB *StorageClassStatusPBPtr;
-
-
- struct StorageClassControlPB {
- USBPB usbPB;
- Boolean busy;
- StorageControlPBPtr userPBPtr;
- };
- typedef struct StorageClassControlPB StorageClassControlPB;
- typedef StorageClassControlPB *StorageClassControlPBPtr;
-
- // Device level
- // Device specific items will be part of another module later
-
-
-
-
- #endif //__STORAGECLASSDRIVERH__